
var myMixin = {
    data() {
        return {
            activeIndex: '1',
            activenavliIndex: 0,
            titleList: ['会员', '套餐', '合作'],
            isLogin: false,
            HeadImageUrl: "../image/index/header.png",
            headerList: [
                {
                    "name": "北美",
                    "universityItems": [
                        {
                            "name": "美国"
                        },
                        {
                            "name": "加拿大"
                        }
                    ],
                    "selSchoolItems": [
                        {
                            "name": "美国选校系统"
                        }
                    ]
                },
                {
                    "name": "英爱",
                    "universityItems": [
                        {
                            "name": "英国"
                        },
                        {
                            "name": "爱尔兰"
                        }
                    ],
                    "selSchoolItems": [
                        {
                            "name": "英国选校系统"
                        },
                        {
                            "name": "英国艺术选校系统"
                        },
                        {
                            "name": "英国Top up 选校系统"
                        },
                        {
                            "name": "爱尔兰选校系统"
                        }
                    ]
                },
                {
                    "name": "澳新",
                    "universityItems": [
                        {
                            "name": "澳大利亚"
                        },
                        {
                            "name": "新西兰"
                        }
                    ],
                    "selSchoolItems": [
                        {
                            "name": "澳大利亚选校系统"
                        },
                        {
                            "name": "新西兰选校系统"
                        }
                    ]
                },
                {
                    "name": "港新",
                    "universityItems": [
                        {
                            "name": "香港"
                        },
                        {
                            "id": "Z04002",
                            "name": "新加坡"
                        }
                    ],
                    "selSchoolItems": [
                        {
                            "name": "港新选校系统"
                        }
                    ]
                },
                {
                    "name": "东南亚",
                    "universityItems": [
                        {
                            "name": "马来西亚"
                        }
                    ],
                    "selSchoolItems": [
                        {
                            "name": "马来西亚选校系统"
                        }
                    ]
                },
                {
                    "name": "欧洲",
                    "universityItems": [
                        {
                            "name": "荷兰"
                        },
                        {
                            "name": "意大利"
                        },
                        {
                            "name": "西班牙"
                        },
                        {
                            "name": "丹麦"
                        },
                        {
                            "name": "法国"
                        },
                        {
                            "name": "德国"
                        },
                        {
                            "name": "比利时"
                        },
                        {
                            "name": "瑞典"
                        },
                        {
                            "name": "芬兰"
                        }
                    ],
                    "selSchoolItems": []
                }
            ],
            znxxxtList: [],
            basicInfo: {},
            nickname: '星辰大海',
            membType: '',
        }
    },
    created() {
        if (localStorage.getItem('token')) {
            this.isLogin = true
            http('userdata/basicInfo', 'post').then(res => {
                console.log('basicInfo', JSON.parse(Decrypt(res.data)));
                let data = JSON.parse(Decrypt(res.data))
                this.basicInfo = data
                if (data.headImageUrl) {
                    this.HeadImageUrl = data.headImageUrl
                }
                if (data.nickname) {
                    this.nickname = data.nickname
                }
            })

            http('basicdata/menudatalist', 'post').then(res => {
                console.log(JSON.parse(Decrypt(res.data)));
                let data = JSON.parse(Decrypt(res.data))
                this.headerList = data
                for (let i of data) {
                    for (let g of i.universityItems) {
                        if (g.name == '荷兰') {
                            g.imgSrc = '../image/index/helan.png'
                        } else if (g.name == '意大利') {
                            g.imgSrc = '../image/index/ydl.png'
                        } else if (g.name == '西班牙') {
                            g.imgSrc = '../image/index/xby.png'
                        } else if (g.name == '丹麦') {
                            g.imgSrc = '../image/index/danmai.png'
                        } else if (g.name == '法国') {
                            g.imgSrc = '../image/index/faguo.png'
                        } else if (g.name == '德国') {
                            g.imgSrc = '../image/index/deguo.png'
                        } else if (g.name == '比利时') {
                            g.imgSrc = '../image/index/bls.png'
                        } else if (g.name == '瑞典') {
                            g.imgSrc = '../image/index/ruidian.png'
                        } else if (g.name == '芬兰') {
                            g.imgSrc = '../image/index/fenlan.png'
                        } else if (g.name == '美国') {
                            g.imgSrc = '../image/index/meiguo.png'
                        } else if (g.name == '加拿大') {
                            g.imgSrc = '../image/index/jnd.png'
                        } else if (g.name == '英国') {
                            g.imgSrc = '../image/index/yingguo.png'
                        } else if (g.name == '爱尔兰') {
                            g.imgSrc = '../image/index/ael.png'
                        } else if (g.name == '澳大利亚') {
                            g.imgSrc = '../image/index/adly.png'
                        } else if (g.name == '新西兰') {
                            g.imgSrc = '../image/index/xxl.png'
                        } else if (g.name == '香港') {
                            g.imgSrc = '../image/index/xianggang.png'
                        } else if (g.name == '新加坡') {
                            g.imgSrc = '../image/index/xjp.png'
                        } else if (g.name == '马来西亚') {
                            g.imgSrc = '../image/index/mlxy.png'
                        }
                    }
                    for (let j of i.selSchoolItems) {
                        if (j.name == '港新选校系统') {
                            j.imgSrc = '../image/index/gangxin.png'
                        } else if (j.name == '英国选校系统') {
                            j.imgSrc = '../image/index/yingguo.png'
                        } else if (j.name == '美国选校系统') {
                            j.imgSrc = '../image/index/meiguo.png'
                        } else if (j.name == '英国艺术选校系统') {
                            j.imgSrc = '../image/index/yingguo.png'
                        } else if (j.name == '澳大利亚选校系统') {
                            j.imgSrc = '../image/index/adly.png'
                        } else if (j.name == '爱尔兰选校系统') {
                            j.imgSrc = '../image/index/ael.png'
                        } else if (j.name == '马来西亚选校系统') {
                            j.imgSrc = '../image/index/mlxy.png'
                        } else if (j.name == '新西兰选校系统') {
                            j.imgSrc = '../image/index/xxl.png'
                        } else if (j.name == '英国Top up 选校系统') {
                            j.imgSrc = '../image/index/yingguo.png'
                        }
                        this.znxxxtList.push(j)
                    }
                }
                console.log('this.znxxxtList', this.znxxxtList);
            })
        } else {
            for (let i of this.headerList) {
                for (let g of i.universityItems) {
                    if (g.name == '荷兰') {
                        g.imgSrc = '../image/index/helan.png'
                    } else if (g.name == '意大利') {
                        g.imgSrc = '../image/index/ydl.png'
                    } else if (g.name == '西班牙') {
                        g.imgSrc = '../image/index/xby.png'
                    } else if (g.name == '丹麦') {
                        g.imgSrc = '../image/index/danmai.png'
                    } else if (g.name == '法国') {
                        g.imgSrc = '../image/index/faguo.png'
                    } else if (g.name == '德国') {
                        g.imgSrc = '../image/index/deguo.png'
                    } else if (g.name == '比利时') {
                        g.imgSrc = '../image/index/bls.png'
                    } else if (g.name == '瑞典') {
                        g.imgSrc = '../image/index/ruidian.png'
                    } else if (g.name == '芬兰') {
                        g.imgSrc = '../image/index/fenlan.png'
                    } else if (g.name == '美国') {
                        g.imgSrc = '../image/index/meiguo.png'
                    } else if (g.name == '加拿大') {
                        g.imgSrc = '../image/index/jnd.png'
                    } else if (g.name == '英国') {
                        g.imgSrc = '../image/index/yingguo.png'
                    } else if (g.name == '爱尔兰') {
                        g.imgSrc = '../image/index/ael.png'
                    } else if (g.name == '澳大利亚') {
                        g.imgSrc = '../image/index/adly.png'
                    } else if (g.name == '新西兰') {
                        g.imgSrc = '../image/index/xxl.png'
                    } else if (g.name == '香港') {
                        g.imgSrc = '../image/index/xianggang.png'
                    } else if (g.name == '新加坡') {
                        g.imgSrc = '../image/index/xjp.png'
                    } else if (g.name == '马来西亚') {
                        g.imgSrc = '../image/index/mlxy.png'
                    }
                }
                for (let j of i.selSchoolItems) {
                    if (j.name == '港新选校系统') {
                        j.imgSrc = '../image/index/gangxin.png'
                    } else if (j.name == '英国选校系统') {
                        j.imgSrc = '../image/index/yingguo.png'
                    } else if (j.name == '美国选校系统') {
                        j.imgSrc = '../image/index/meiguo.png'
                    } else if (j.name == '英国艺术选校系统') {
                        j.imgSrc = '../image/index/yingguo.png'
                    } else if (j.name == '澳大利亚选校系统') {
                        j.imgSrc = '../image/index/adly.png'
                    } else if (j.name == '爱尔兰选校系统') {
                        j.imgSrc = '../image/index/ael.png'
                    } else if (j.name == '马来西亚选校系统') {
                        j.imgSrc = '../image/index/mlxy.png'
                    } else if (j.name == '新西兰选校系统') {
                        j.imgSrc = '../image/index/xxl.png'
                    } else if (j.name == '英国Top up 选校系统') {
                        j.imgSrc = '../image/index/yingguo.png'
                    }
                    this.znxxxtList.push(j)
                }
            }
        }
    },
    methods: {
        menuSelect(key, keyPath) {
            if (key == 2) {
                if (!this.isLogin) {
                    location.href = './member.html'
                } else {
                    location.href = './memberLogin.html'
                }
            }
            if (key == 3) {
                if (!this.isLogin) {
                    location.href = './fuelBag.html'
                } else {
                    location.href = './memberNewUser.html'
                }

            }
            if (key == 4) {
                location.href = './cooperate.html'
            }
        },
        unavclcik(index) {
            console.log(index);
            this.activenavliIndex = index
        },
        tabClick(index) {
            this.tabactiveIndex = index
        },
        login() {
            window.location.href = './login.html'
        },
        goHome() {
            window.location.href = './index.html'
        },
        goUser() {
            window.location.href = './user.html'
        },
        layoutLogin() {
            this.isLogin = false
            localStorage.clear()
            location.href = './index.html'
        },
        qqyxkClick(id, id1) {
            http('basicdata/queryuniversitylist?querycode=' + id1, 'post').then(res => {
                if (!res) {
                    this.$message.error('请先登录')
                }
                console.log(JSON.parse(Decrypt(res.data)));
                let data = JSON.parse(Decrypt(res.data))
                if (data.length <= 0) {
                    location.href = './qqyxkError.html?id=' + JSON.stringify([id, id1])
                } else {
                    location.href = './qqyxk.html?id=' + JSON.stringify([id, id1])
                }
            })
        },
        znxxxtSearch(item) {
            http('basicdata/mauniselpara?querycode=' + item.id, 'post').then(res => {
                if (!res) {
                    this.$message.error('请先登录')
                }
                console.log('意向院校：', JSON.parse(Decrypt(res.data)));
                let data = JSON.parse(Decrypt(res.data))
                if (data.length == 0) {
                    location.href = './znxxxtError.html'
                } else {
                    location.href = './znxxxtSearch.html'
                }
            })
            localStorage.znxxxtSearch = JSON.stringify(item)
        },
        getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null && r[2] != "false")
                return unescape(r[2]);
            return false;
        }
    }
}
// 使用Vue.extend来创建一个组件，并混入mixin
var MyComponent = Vue.extend({
    mixins: [myMixin],
    template: ` `
})